package view;

import java.text.NumberFormat;

public class OrdreLinieForm extends javax.swing.JPanel {

     private int ordreid;
     private boolean betalt;
     private boolean modtaget;
     private double sum;
     private Client gui; 
    
    public OrdreLinieForm( Client gui, int ordreid, boolean betalt, boolean modtaget, double sum ) {
        initComponents();
        this.gui = gui;
        this.ordreid = ordreid;
        this.betalt = betalt;
        this.modtaget= modtaget;
        this.sum = sum;
        
        jLabel_ordreid.setText("id " + ordreid);
        
        String betaltsvar = (betalt)?"JA":"NEJ";
        jLabel_betalt.setText(betaltsvar);
        
        String modtagetsvar = (modtaget)?"JA":"NEJ";
        jLabel_modtaget.setText(modtagetsvar);
        
        if (modtaget) {
            jButton1.setEnabled(false);
            jButton1.setVisible(false);
        }

         NumberFormat fmt = NumberFormat.getCurrencyInstance();
        
        jLabel_sum.setText( fmt.format( sum ));
        
        System.out.println("ordre linie " + ordreid + " b " + betaltsvar + " m " + modtagetsvar + "  s " + sum );
        

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel_ordreid = new javax.swing.JLabel();
        jLabel_betalt = new javax.swing.JLabel();
        jLabel_modtaget = new javax.swing.JLabel();
        jLabel_sum = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setLayout(null);

        jLabel_ordreid.setText("dd");
        add(jLabel_ordreid);
        jLabel_ordreid.setBounds(10, 0, 60, 30);

        jLabel_betalt.setText("jLabel1");
        add(jLabel_betalt);
        jLabel_betalt.setBounds(50, 0, 60, 30);

        jLabel_modtaget.setText("jLabel1");
        add(jLabel_modtaget);
        jLabel_modtaget.setBounds(100, 0, 34, 30);

        jLabel_sum.setText("jLabel1");
        add(jLabel_sum);
        jLabel_sum.setBounds(180, 0, 90, 30);

        jButton1.setText("MODTAG");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1);
        jButton1.setBounds(280, 0, 75, 23);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        gui.setOrdreTilAtVaereModtaget( ordreid );
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel_betalt;
    private javax.swing.JLabel jLabel_modtaget;
    private javax.swing.JLabel jLabel_ordreid;
    private javax.swing.JLabel jLabel_sum;
    // End of variables declaration//GEN-END:variables
}
